package com.ruoyi.statistic.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.statistic.domain.StatisticStudentEmploymentFile;
import com.ruoyi.statistic.domain.vo.StatisticStudentEmploymentFileSearchVo;
import com.ruoyi.statistic.mapper.StatisticStudentEmploymentFileMapper;
import com.ruoyi.statistic.service.IStatisticStudentEmploymentFileService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 学生就业数据文件管理Service业务层处理
 *
 * @author linyang
 * @date 2023-02-15
 */
@Service
public class StatisticStudentEmploymentFileServiceImpl implements IStatisticStudentEmploymentFileService {

    @Resource
    private StatisticStudentEmploymentFileMapper statisticStudentEmploymentFileMapper;

    /**
     * 查询学生就业数据文件管理
     *
     * @param id 学生就业数据文件管理主键
     * @return 学生就业数据文件管理
     */
    @Override
    public StatisticStudentEmploymentFile selectStatisticStudentEmploymentFileById(Long id) {
        return statisticStudentEmploymentFileMapper.selectStatisticStudentEmploymentFileById(id);
    }

    /**
     * 就业年份
     *
     * @param year
     * @param date
     * @return
     */
    @Override
    public StatisticStudentEmploymentFile selectStatisticStudentEmploymentFileByDate(String year, Date date) {
        return statisticStudentEmploymentFileMapper.selectStatisticStudentEmploymentFileByDate(year, date);
    }


    /**
     * 判断是否存在指定日期的文件
     *
     * @param date
     * @return
     */
//    @Override
//    public StudentEmploymentFile selectStudentEmploymentFileByYearAndDate(String year, Date date) {
//        return studentEmploymentFileMapper.selectStudentEmploymentFileByYearAndDate(year, date);
//    }

    /**
     * 查询学生就业数据文件管理列表
     *
     * @param vo
     * @return
     */
    @Override
    public List<StatisticStudentEmploymentFile> selectStatisticStudentEmploymentFileList(StatisticStudentEmploymentFileSearchVo vo) {
        return statisticStudentEmploymentFileMapper.selectStatisticStudentEmploymentFileList(vo);
    }


    /**
     * 新增学生就业数据文件管理
     *
     * @param statisticStudentEmploymentFile 学生就业数据文件管理
     * @return 结果
     */
    @Override
    public int insertStatisticStudentEmploymentFile(StatisticStudentEmploymentFile statisticStudentEmploymentFile) {
        statisticStudentEmploymentFile.setCreateTime(DateUtils.getNowDate());
        return statisticStudentEmploymentFileMapper.insertStatisticStudentEmploymentFile(statisticStudentEmploymentFile);
    }

    /**
     * 修改学生就业数据文件管理
     *
     * @param studentEmploymentFile 学生就业数据文件管理
     * @return 结果
     */
    @Override
    public int updateStatisticStudentEmploymentFile(StatisticStudentEmploymentFile studentEmploymentFile) {
        studentEmploymentFile.setUpdateTime(DateUtils.getNowDate());
        return statisticStudentEmploymentFileMapper.updateStatisticStudentEmploymentFile(studentEmploymentFile);
    }

    /**
     * 批量删除学生就业数据文件管理
     *
     * @param ids 需要删除的学生就业数据文件管理主键
     * @return 结果
     */
    @Override
    public int deleteStatisticStudentEmploymentFileByIds(Long[] ids) {
        return statisticStudentEmploymentFileMapper.deleteStatisticStudentEmploymentFileByIds(ids);
    }

    /**
     * 删除学生就业数据文件管理信息
     *
     * @param id 学生就业数据文件管理主键
     * @return 结果
     */
    @Override
    public int deleteStatisticStudentEmploymentFileById(Long id) {
        return statisticStudentEmploymentFileMapper.deleteStatisticStudentEmploymentFileById(id);
    }


    /**
     * 删除学生就业数据文件管理信息
     *
     * @param year
     * @param date
     * @return
     */
    public int deleteStatisticStudentEmploymentFileByDate(String year, Date date) {
        return statisticStudentEmploymentFileMapper.deleteStatisticStudentEmploymentFileByDate(year, date);
    }


    /**
     * 获取最后一次文件上传日期
     *
     * @return
     */
    public Date selectLastFileDate(String year) {
        return statisticStudentEmploymentFileMapper.selectLastFileDate(year);
    }


    /**
     * 获取近N天的文件数据
     *
     * @param year 所属毕业年份
     * @param days 近N天
     * @return
     */
    @Override
    public List<StatisticStudentEmploymentFile> selectRecentDaysFile(String year, Integer days) {
        return statisticStudentEmploymentFileMapper.selectRecentDaysFile(year, days);
    }


    /**
     * 获取当前年份最新数据的日期
     *
     * @param year
     * @return
     */
    @Override
    public Date selectMaxDateByYear(String year) {
        return statisticStudentEmploymentFileMapper.selectMaxDateByYear(year);
    }
}
